package com.tan.model.vo;

import com.tan.model.domain.UserInfo;
import com.tan.model.mongo.Comment;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class LikeVo implements Serializable {
    private String id;
    private String avatar;
    private String nickname;
    private String createDate;
    public static LikeVo init(UserInfo userInfo, Comment comment) {
    LikeVo vo = new LikeVo();
    BeanUtils.copyProperties(userInfo, vo);
        Date date = new Date(comment.getCreated());
        vo.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date));
        vo.setId(comment.getPublishId().toHexString());
     return vo;
    }
}
